<?php
//1 获取场馆ID及分区ID  2 场次信息
// $sign =  md5('1236242015-08-17ShowINF207002'); 
// $aaaa=  file_get_contents('http://www.12301.cc/api/pft_show/pft_show.php?method=ShowINF&account=123624&type=2&tid=20700&date=2015-08-17&sign='.$sign);
// print_r(json_decode($aaaa,true));exit;


// 1 获取场馆信息及座位总数  2 获取座位详细
// $sign =  md5('GetVenueINF142'); 
// $aaaa=  file_get_contents('http://www.12301.cc/api/pft_show/pft_show_inside.php?method=GetVenueINF&venue_id=42&type=1&sign='.$sign);
// print_r(json_decode($aaaa,true));exit;;

// $txt=file_get_contents('php://input');
// logfile("-----------------------------".date('Y-m-d H:i:s')."-----------------------------------",'qunar_coop_log.txt');
// logfile($txt,'qunar_coop_log.txt');
$ac1='16ucom';
$pw1='c33367701511b4f6020ec61ded352059';
$inSide = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac1|pw_16u=$pw1|auth_16u=true"));

$time22 = microtime(true);
include("/var/www/html/new/conf/le.je");
$le=new go_sql();
$le->connect();

$tid_aid = '20690_3385';
$ids = explode('_',$tid_aid);
$tid = $ids[0];
$aid = $ids[1];
 
$str="select a.id as lid,a.title as ltitle,a.jqts,b.title as ttitle ,a.address,a.delaytime,b.pay,b.buy_limit_up,b.buy_limit_low,b.order_end,b.order_start,b.delaytype,b.delaydays,b.notes,b.tprice,b.ddays,b.pid,b.getaddr,b.cancel_auto_onMin,d.dhour from uu_land a inner join uu_jq_ticket b on (a.id = b.landid) left join uu_products c on(b.pid = c.id) left join uu_land_f d on(b.id = d.tid) where b.id='$tid' and c.apply_limit = 1 and c.p_status = 0 limit 1";
$GLOBALS['le']->query($str);
$row = $GLOBALS['le']->fetch_assoc();
// print_r($row);exit;
$account =  '123624';
$time = date('Y-m-d');
$get_ShowINF = array('method'=>'ShowINF','account'=>$account,'tid'=>$tid,'type'=>2,'date'=>$time,"mulit"=>3);
ksort($get_ShowINF);
$token_str = implode('', $get_ShowINF);
$get_ShowINF['sign'] = md5($token_str); 

//获取场次
$get_ShowINF_data=  json_decode(file_get_contents("http://www.12301.cc/api/pft_show/pft_show.php?".http_build_query($get_ShowINF)),true);
// print_r($get_ShowINF_data);exit;
//获取分区
$venue_id =$get_ShowINF_data['venue_id'];
$zone_id = $get_ShowINF_data['zone_id'];
$pft_show_inside_data =  json_decode(file_get_contents("http://www.12301.cc/api/pft_show/pft_show_inside.php?method=GetVenueINF&venue_id=$venue_id&type=1&zone_id=$zone_id"),true);

$fqname  = $pft_show_inside_data['zone_list'][$get_ShowINF_data['zone_id']];
$i = 0;
foreach($get_ShowINF_data['rounds'] as $key=>$as){
	// print_r($k);exit;
	foreach($as as $value){
		$specification =<<<xml
		 <specification>
			<code></code>
			<name></name>
			<valueNames>
				<valueName>{$value['round_name']}</valueName>
			</valueNames>
		</specification>
xml;
		$specifications.= $specification;
		
		$skuspecification = <<<xml
			<specification>
				<code>screening</code>
				<name>场次</name>
				<valueName>{$k['round_name']}</valueName>
			</specification>
			<specification>
				<code>seat</code>
				<name>坐席</name>
				<valueName>{$fqname}</valueName>
			</specification>
xml;
		$skuspecifications.=$skuspecification;
	}
}
echo $skuspecifications;exit;
$response_xml = response_body($row,$get_ShowINF_data,$specifications,$skuspecifications);
function response_body($row,$get_ShowINF_data,$specifications,$skuspecifications){
	$response = <<<xml
	<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<response xmlns="http://piao.qunar.com/2013/QMenpiaoResponseSchema">
    <header>
        <application>Qunar.Menpiao.Agent</application>
        <processor>SupplierDataExchangeProcessor</processor>
        <version>v2.0.0</version>
        <bodyType>GetCategoryProductByQunarResponseBody</bodyType>
        <createUser>Qunar.Menpiao.Agent</createUser>
        <createTime>2015-08-14 16:52:17</createTime>
        <code>String</code>
        <describe>String</describe>
    </header>
    <body xsi:type="GetCategoryProductByQunarResponseBody" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <productInfos>
            <productInfo>
                <baseInfo>
                    <spuResourceId>identity_7123326</spuResourceId>
                    <saleType>B2C</saleType>
                    <suggestPrice></suggestPrice>
                    <sights>
                        <sight>
                            <sightName>{$row['ltitle']}</sightName>
                            <sightAddress>{$row['address']}</sightAddress>
                            <city>{$row['address']}</city>
                        </sight>
                    </sights>
                    <productName>{$row['ltitle']}{$row['ttitle']}</productName>
                    <categoryName>{$get_ShowINF_data['venue_id']}</categoryName>
                    <specifications>
						{$specifications}
                    </specifications>
                    <propInfos>
                        <propInfo>
                            <name></name>
                            <value></value>
                        </propInfo>
                        <propInfo>
                            <name></name>
                            <value></value>
                        </propInfo>
                    </propInfos>
                </baseInfo>
                <bookConfig>
                    <paymentType></paymentType>
                    <autoCancelTime></autoCancelTime>
                    <contactPersonRequired>
                        <nameRequired></nameRequired>
                        <namePinyinRequired></namePinyinRequired>
                        <emailRequired></emailRequired>
                        <addressRequired></addressRequired>
                    </contactPersonRequired>
                    <bookPersonType xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema"></bookPersonType>
                    <visitPersonRequiredForQuantity></visitPersonRequiredForQuantity>
                    <visitPersonRequired>
                        <nameRequired></nameRequired>
                        <namePinYinRequired></namePinYinRequired>
                        <credentialsRequired></credentialsRequired>
                        <credentialsRequiredTypes></credentialsRequiredTypes>
                    </visitPersonRequired>
                    <perPhoneMaximum></perPhoneMaximum>
                    <perPhoneMaximumType></perPhoneMaximumType>
                    <perCredentialMaximum></perCredentialMaximum>
                </bookConfig>
                <skus>
                    <skuInfos>
                        <skuInfo>
                            <skuResourceId></skuResourceId>
                            <specifications>
								{$skuspecifications}
							</specifications>
                            <priceConfig>
                                <validType></validType>
                                <dayUseTimePeriod></dayUseTimePeriod>
                                <calendarPrices>
                                    <calendarPrice>
                                        <useDate></useDate>
                                        <marketPrice></marketPrice>
                                        <sellPrice></sellPrice>
                                        <settlePrice></settlePrice>
                                        <sellstock></sellstock>
                                        <minimum></minimum>
                                        <maximum></maximum>
                                    </calendarPrice>
                                    <calendarPrice>
                                        <useDate></useDate>
                                        <marketPrice></marketPrice>
                                        <sellPrice></sellPrice>
                                        <settlePrice></settlePrice>
                                        <sellstock></sellstock>
                                        <minimum></minimum>
                                        <maximum></maximum>
                                    </calendarPrice>
                                    <calendarPrice>
                                        <useDate></useDate>
                                        <marketPrice></marketPrice>
                                        <sellPrice></sellPrice>
                                        <settlePrice></settlePrice>
                                        <sellstock></sellstock>
                                        <maximum></maximum>
                                    </calendarPrice>
                                </calendarPrices>
                                <periodPrice>
                                    <periodStart></periodStart>
                                    <periodEnd></periodEnd>
                                    <validWeek></validWeek>
                                    <invalidDate></invalidDate>
                                    <marketPrice></marketPrice>
                                    <sellPrice></sellPrice>
                                    <settlePrice></settlePrice>
                                    <sellstock></sellstock>
                                    <minimum></minimum>
                                    <maximum></maximum>
                                </periodPrice>
                            </priceConfig>
                        </skuInfo>
                        <skuInfo>
                            <skuResourceId></skuResourceId>
                            <specifications />
                            <propInfos />
                            <priceConfig>
                                <validType></validType>
                                <dayUseTimePeriod></dayUseTimePeriod>
                                <calendarPrices>
                                    <calendarPrice>
                                        <useDate></useDate>
                                        <marketPrice></marketPrice>
                                        <sellPrice></sellPrice>
                                        <settlePrice></settlePrice>
                                        <sellstock></sellstock>
                                        <minimum></minimum>
                                        <maximum></maximum>
                                    </calendarPrice>
                                    <calendarPrice>
                                        <useDate></useDate>
                                        <marketPrice></marketPrice>
                                        <sellPrice></sellPrice>
                                        <settlePrice></settlePrice>
                                        <sellstock></sellstock>
                                        <minimum></minimum>
                                        <maximum></maximum>
                                    </calendarPrice>
                                    <calendarPrice>
                                        <useDate></useDate>
                                        <marketPrice></marketPrice>
                                        <sellPrice></sellPrice>
                                        <settlePrice></settlePrice>
                                        <sellstock></sellstock>
                                        <maximum></maximum>
                                    </calendarPrice>
                                </calendarPrices>
                                <periodPrice>
                                    <periodStart></periodStart>
                                    <periodEnd></periodEnd>
                                    <validWeek></validWeek>
                                    <invalidDate></invalidDate>
                                    <marketPrice></marketPrice>
                                    <sellPrice></sellPrice>
                                    <settlePrice></settlePrice>
                                    <sellstock></sellstock>
                                    <minimum></minimum>
                                    <maximum></maximum>
                                </periodPrice>
                            </priceConfig>
                        </skuInfo>
                    </skuInfos>
                </skus>
                <promoteConfig>
                    <cashBackMoney></cashBackMoney>
                </promoteConfig>
                <productDescription>
                    <feeInfo></feeInfo>
                    <feeInclude></feeInclude>
                    <feeExclude></feeExclude>
                    <pickupTime></pickupTime>
                    <pickupAddress></pickupAddress>
                    <remind></remind>
                    <refundOption>
                        <canRefund></canRefund>
                        <refundApplyTimeBeforeValidEndDay></refundApplyTimeBeforeValidEndDay>
                        <refundChargeType></refundChargeType>
                        <refundCharge></refundCharge>
                        <refundInfo></refundInfo>
                    </refundOption>
                </productDescription>
                <otherConfig>
                    <telephone></telephone>
                    <salePeriods>
                        <salePeriod>
                            <saleStartTime></saleStartTime>
                            <saleEndTime></saleEndTime>
                        </salePeriod>
                    </salePeriods>
                    <smsTemplet></smsTemplet>
                    <eticketType></eticketType>
                </otherConfig>
            </productInfo>
        </productInfos>
    </body>
</response>
xml;
		return $response;
}

?>